diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 6cb877f..8ac7caa 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -40,6 +40,54 @@
 {
 
 /**
+ * @brief Retrieves resources over dbus to link to the chassis
+ *
+ * @param[in] asyncResp  - Shared pointer for completing asynchronous
+ * calls
+ * @param[in] path       - Chassis dbus path to look for the storage.
+ *
+ * Calls the Association endpoints on the path + "/storage" and add the link of
+ * json["Links"]["Storage@odata.count"] =
+ *    {"@odata.id", "/redfish/v1/Storage/" + resourceId}
+ *
+ * @return None.
+ */
+inline void getStorageLink(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+                           const sdbusplus::message::object_path& path)
+{
+    sdbusplus::asio::getProperty<std::vector<std::string>>(
+        *crow::connections::systemBus, "xyz.openbmc_project.ObjectMapper",
+        (path / "storage").str, "xyz.openbmc_project.Association", "endpoints",
+        [asyncResp](const boost::system::error_code ec,
+                    const std::vector<std::string>& storageList) {
+        if (ec)
+        {
+            BMCWEB_LOG_DEBUG << "getStorageLink got DBUS response error";
+            return;
+        }
+
+        nlohmann::json::array_t storages;
+        for (const std::string& storagePath : storageList)
+        {
+            std::string id =
+                sdbusplus::message::object_path(storagePath).filename();
+            if (id.empty())
+            {
+                continue;
+            }
+
+            nlohmann::json::object_t storage;
+            storage["@odata.id"] = boost::urls::format(
+                "/redfish/v1/Systems/system/Storage/{}", id);
+            storages.emplace_back(std::move(storage));
+        }
+        asyncResp->res.jsonValue["Links"]["Storage@odata.count"] =
+            storages.size();
+        asyncResp->res.jsonValue["Links"]["Storage"] = std::move(storages);
+        });
+}
+
+/**
  * @brief Retrieves chassis state properties over dbus
  *
  * @param[in] asyncResp - Shared pointer for completing asynchronous calls.
@@ -379,9 +427,9 @@
             sdbusplus::asio::getAllProperties(
                 *crow::connections::systemBus, connectionName, path,
                 "xyz.openbmc_project.Inventory.Decorator.Asset",
-                [asyncResp, chassisId(std::string(chassisId))](
-                    const boost::system::error_code& /*ec2*/,
-                    const dbus::utility::DBusPropertiesMap& propertiesList) {
+                [asyncResp, chassisId(std::string(chassisId)),
+                 path](const boost::system::error_code& /*ec2*/,
+                       const dbus::utility::DBusPropertiesMap& propertiesList) {
                 const std::string* partNumber = nullptr;
                 const std::string* serialNumber = nullptr;
                 const std::string* manufacturer = nullptr;
@@ -470,6 +518,7 @@
                 asyncResp->res.jsonValue["Links"]["ManagedBy"] =
                     std::move(managedBy);
                 getChassisState(asyncResp);
+                getStorageLink(asyncResp, path);
                 });
 
             for (const auto& interface : interfaces2)
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index 53af1f1..fce53f4 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -27,6 +27,7 @@
 #include "query.hpp"
 #include "redfish_util.hpp"
 #include "registries/privilege_registry.hpp"
+#include "utils/collection.hpp"
 #include "utils/dbus_utils.hpp"
 
 #include <boost/system/error_code.hpp>
@@ -61,12 +62,32 @@
     asyncResp->res.jsonValue["@odata.id"] =
         "/redfish/v1/Systems/system/Storage";
     asyncResp->res.jsonValue["Name"] = "Storage Collection";
-    nlohmann::json::array_t members;
-    nlohmann::json::object_t member;
-    member["@odata.id"] = "/redfish/v1/Systems/system/Storage/1";
-    members.emplace_back(member);
-    asyncResp->res.jsonValue["Members"] = std::move(members);
-    asyncResp->res.jsonValue["Members@odata.count"] = 1;
+
+    constexpr std::array<std::string_view, 1> interface {
+        "xyz.openbmc_project.Inventory.Item.Storage"
+    };
+    collection_util::getCollectionMembers(
+        asyncResp, boost::urls::format("/redfish/v1/Systems/system/Storage"),
+        interface);
+}
+
+inline void handleStorageCollectionGet(
+    App& app, const crow::Request& req,
+    const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
+{
+    if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+    {
+        return;
+    }
+    asyncResp->res.jsonValue["@odata.type"] =
+        "#StorageCollection.StorageCollection";
+    asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Storage";
+    asyncResp->res.jsonValue["Name"] = "Storage Collection";
+    constexpr std::array<std::string_view, 1> interface {
+        "xyz.openbmc_project.Inventory.Item.Storage"
+    };
+    collection_util::getCollectionMembers(
+        asyncResp, boost::urls::format("/redfish/v1/Storage"), interface);
 }
 
 inline void requestRoutesStorageCollection(App& app)
@@ -75,6 +96,11 @@
         .privileges(redfish::privileges::getStorageCollection)
         .methods(boost::beast::http::verb::get)(
             std::bind_front(handleSystemsStorageCollectionGet, std::ref(app)));
+
+    BMCWEB_ROUTE(app, "/redfish/v1/Storage/")
+        .privileges(redfish::privileges::getStorageCollection)
+        .methods(boost::beast::http::verb::get)(
+            std::bind_front(handleStorageCollectionGet, std::ref(app)));
 }
 
 inline void afterChassisDriveCollectionSubtree(
@@ -129,19 +155,37 @@
         std::bind_front(afterChassisDriveCollectionSubtree, asyncResp, health));
 }
 
-inline void
-    handleSystemsStorageGet(App& app, const crow::Request& req,
-                            const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
+inline void afterSystemsStorageGetSubtree(
+    const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+    const std::string& storageId, const boost::system::error_code& ec,
+    const dbus::utility::MapperGetSubTreeResponse& subtree)
 {
-    if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+    if (ec)
     {
+        BMCWEB_LOG_DEBUG << "requestRoutesStorage DBUS response error";
+        messages::resourceNotFound(asyncResp->res, "#Storage.v1_13_0.Storage",
+                                   storageId);
         return;
     }
+    auto storage = std::find_if(
+        subtree.begin(), subtree.end(),
+        [&storageId](const std::pair<std::string,
+                                     dbus::utility::MapperServiceMap>& object) {
+        return sdbusplus::message::object_path(object.first).filename() ==
+               storageId;
+        });
+    if (storage == subtree.end())
+    {
+        messages::resourceNotFound(asyncResp->res, "#Storage.v1_13_0.Storage",
+                                   storageId);
+        return;
+    }
+
     asyncResp->res.jsonValue["@odata.type"] = "#Storage.v1_13_0.Storage";
     asyncResp->res.jsonValue["@odata.id"] =
-        "/redfish/v1/Systems/system/Storage/1";
+        boost::urls::format("/redfish/v1/Systems/system/Storage/{}", storageId);
     asyncResp->res.jsonValue["Name"] = "Storage";
-    asyncResp->res.jsonValue["Id"] = "1";
+    asyncResp->res.jsonValue["Id"] = storageId;
     asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
 
     auto health = std::make_shared<HealthPopulate>(asyncResp);
@@ -151,16 +195,100 @@
     }
 
     getDrives(asyncResp, health);
-    asyncResp->res.jsonValue["Controllers"]["@odata.id"] =
-        "/redfish/v1/Systems/system/Storage/1/Controllers";
+    asyncResp->res.jsonValue["Controllers"]["@odata.id"] = boost::urls::format(
+        "/redfish/v1/Systems/system/Storage/{}/Controllers", storageId);
+}
+
+inline void
+    handleSystemsStorageGet(App& app, const crow::Request& req,
+                            const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+                            const std::string& storageId)
+{
+    if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+    {
+        return;
+    }
+
+    constexpr std::array<std::string_view, 1> interfaces = {
+        "xyz.openbmc_project.Inventory.Item.Storage"};
+    dbus::utility::getSubTree(
+        "/xyz/openbmc_project/inventory", 0, interfaces,
+        std::bind_front(afterSystemsStorageGetSubtree, asyncResp, storageId));
+}
+
+inline void afterSubtree(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+                         const std::string& storageId,
+                         const boost::system::error_code& ec,
+                         const dbus::utility::MapperGetSubTreeResponse& subtree)
+{
+    if (ec)
+    {
+        BMCWEB_LOG_DEBUG << "requestRoutesStorage DBUS response error";
+        messages::resourceNotFound(asyncResp->res, "#Storage.v1_13_0.Storage",
+                                   storageId);
+        return;
+    }
+    auto storage = std::find_if(
+        subtree.begin(), subtree.end(),
+        [&storageId](const std::pair<std::string,
+                                     dbus::utility::MapperServiceMap>& object) {
+        return sdbusplus::message::object_path(object.first).filename() ==
+               storageId;
+        });
+    if (storage == subtree.end())
+    {
+        messages::resourceNotFound(asyncResp->res, "#Storage.v1_13_0.Storage",
+                                   storageId);
+        return;
+    }
+
+    asyncResp->res.jsonValue["@odata.type"] = "#Storage.v1_13_0.Storage";
+    asyncResp->res.jsonValue["@odata.id"] =
+        boost::urls::format("/redfish/v1/Storage/{}", storageId);
+    asyncResp->res.jsonValue["Name"] = "Storage";
+    asyncResp->res.jsonValue["Id"] = storageId;
+    asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
+
+    // Storage subsystem to Storage link.
+    nlohmann::json::array_t storageServices;
+    nlohmann::json::object_t storageService;
+    storageService["@odata.id"] =
+        boost::urls::format("/redfish/v1/Systems/system/Storage/{}", storageId);
+    storageServices.emplace_back(storageService);
+    asyncResp->res.jsonValue["Links"]["StorageServices"] =
+        std::move(storageServices);
+    asyncResp->res.jsonValue["Links"]["StorageServices@odata.count"] = 1;
+}
+
+inline void
+    handleStorageGet(App& app, const crow::Request& req,
+                     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+                     const std::string& storageId)
+{
+    if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+    {
+        BMCWEB_LOG_DEBUG << "requestRoutesStorage setUpRedfishRoute failed";
+        return;
+    }
+
+    constexpr std::array<std::string_view, 1> interfaces = {
+        "xyz.openbmc_project.Inventory.Item.Storage"};
+    dbus::utility::getSubTree(
+        "/xyz/openbmc_project/inventory", 0, interfaces,
+        std::bind_front(afterSubtree, asyncResp, storageId));
 }
 
 inline void requestRoutesStorage(App& app)
 {
-    BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Storage/1/")
+    BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Storage/<str>/")
         .privileges(redfish::privileges::getStorage)
         .methods(boost::beast::http::verb::get)(
             std::bind_front(handleSystemsStorageGet, std::ref(app)));
+
+    BMCWEB_ROUTE(app, "/redfish/v1/Storage/<str>/")
+        .privileges(redfish::privileges::getStorage)
+        .methods(boost::beast::http::verb::get)(
+            std::bind_front(handleStorageGet, std::ref(app)));
 }
 
 inline void getDriveAsset(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
